<?php
	include("conn.php");

	$startRow = 0;
	$pageSize = 10;
	if (!empty($_REQUEST['startRow'])) {
		$startRow = $_REQUEST['startRow'];
	}
	if (!empty($_REQUEST['pageSize'])) {
		$pageSize = $_REQUEST['pageSize'];
	};

	$total = 0;
	$count = mysql_query("select count(1) from `ui_datagrid`");
	while($rc = mysql_fetch_row($count)) {
		$total = $rc[0];
	}

	$sql = "select * from `ui_datagrid` limit $startRow,$pageSize";
	$query = mysql_query($sql);
	$arr = array();

	while($rs = mysql_fetch_array($query)) {
		array_push($arr,'{"code":"'.$rs['code'].'","company":"'.$rs['company'].'","name":"'.$rs['name'].'","areacode":"'.$rs['areacode'].'"}');
	}
	echo '{"total":'.$total.',"data":['.join(",",$arr).']}';
?>